package com.czl.module_storehouse.mvp.presenter;

import com.czl.module_base.bean.CompanyBean;
import com.czl.module_base.bean.ListBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_base.mvp.presenter.BasePresenter;
import com.czl.module_base.mvp.view.SimpleView;
import com.czl.module_base.observer.AbsHandleSubscriber;
import com.czl.module_storehouse.bean.WorkGroupBean;
import com.czl.module_storehouse.bean.WorkerBean;
import com.czl.module_storehouse.mvp.model.CompanyModel;

import java.util.List;

/**
 * @author by xubin,
 * @date on 2022/2/11.
 * PS: Not easy to write code, please indicate.
 */
public class CompanyPresenter extends BasePresenter<CompanyModel, SimpleView> {
    public static final String TAG_COMPANY_LIST = "company_list";
    public static final String TAG_COMPANY_GROUP = "company_group";
    public static final String TAG_COMPANY_USER_LIST = "company_user_list";

    public void selectCompanyList() {
        doSubscribe2(mModel.selectCompanyList(), new AbsHandleSubscriber<HttpResponse<List<CompanyBean>>>() {
            @Override
            public void onSuccess(HttpResponse<List<CompanyBean>> listHttpResponse) {
                listHttpResponse.setRequestTag(TAG_COMPANY_LIST);
                mView.showHttpResponse(listHttpResponse);
            }
        });
    }

    public void selectByCompanyId(Integer propCompanyId) {

    }

    public void selectCrmCompanyByTag() {
        doSubscribe2(mModel.selectCrmCompanyByTag(), new AbsHandleSubscriber<HttpResponse<ListBean<CompanyBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<CompanyBean>> listHttpResponse) {
                listHttpResponse.setRequestTag(TAG_COMPANY_LIST);
                mView.showHttpResponse(listHttpResponse);
            }
        });
    }

    /**
     * 获取部门信息
     */
    public void selectOrganization() {
        doSubscribe2(mModel.selectOrganization(), new AbsHandleSubscriber<HttpResponse<ListBean<WorkGroupBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<WorkGroupBean>> listHttpResponse) {
                listHttpResponse.setRequestTag(TAG_COMPANY_GROUP);
                mView.showHttpResponse(listHttpResponse);
            }
        });
    }

    public void selectOrganization(String companyId) {
        doSubscribe2(mModel.selectOrganization(companyId), new AbsHandleSubscriber<HttpResponse<ListBean<WorkGroupBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<WorkGroupBean>> listHttpResponse) {
                listHttpResponse.setRequestTag(TAG_COMPANY_GROUP);
                mView.showHttpResponse(listHttpResponse);
            }
        });
    }

    public void selectUsersByCompanyId(String organizationId) {
        doSubscribe2(mModel.selectUsersByCompanyId(organizationId), new AbsHandleSubscriber<HttpResponse<ListBean<WorkerBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<WorkerBean>> listHttpResponse) {
                listHttpResponse.setRequestTag(TAG_COMPANY_USER_LIST);
                mView.showHttpResponse(listHttpResponse);
            }
        });
    }

    public void selectUsersByCompanyId(String applyCompanyId, String organizationId) {
        doSubscribe2(mModel.selectUsersByCompanyId(applyCompanyId, organizationId), new AbsHandleSubscriber<HttpResponse<ListBean<WorkerBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<WorkerBean>> listHttpResponse) {
                listHttpResponse.setRequestTag(TAG_COMPANY_USER_LIST);
                mView.showHttpResponse(listHttpResponse);
            }
        });
    }
}
